package com.example.productserver.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.example.productserver.model.dto.ProductIdDTO;
import com.example.productserver.model.vo.ProductInfoVO;
import com.example.productserver.result.ResultData;
import com.example.productserver.sentinel.CommonBlockHandler;
import com.example.productserver.sentinel.CommonFallback;
import com.example.productserver.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/productController/")
@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    @PostMapping("selectProductInfoList")
    @SentinelResource(value = "selectProductInfoList",
            blockHandlerClass = CommonBlockHandler.class,
            blockHandler = "handleException",
            fallbackClass = CommonFallback.class,
            fallback = "fallback")
    public ResultData<ProductInfoVO> selectProductInfoList(@RequestBody ProductIdDTO productIdDTO){
        return productService.selectProductInfoList(productIdDTO);
    }


}
